Ext.ns('images');
images.getData = function(page_id){
	Ext.Ajax.request({
		url:  'includes/album.php',
		method: 'POST',
		params: {act : 'onpress',
				 page : page_id},
		success: function ( result, request ){
			var data = Ext.decode(result.responseText).images;
			var count_on = 0;
			var max = 6;
			list ="<p class='titlebar'>&nbsp;&nbsp;&nbsp;&nbsp;ON PRESS!</p>";
			if(data.length < 6){
				max = data.length;
			}
			if(data.length-1 > 0){
				list += "<ul style='clear:both; padding-top:12px'>";
				var index = -1;
				var index2 =0;
				var list_images = new Array();
				for(var i = 0; i < max; i++){
					list_images[i]= new Array();
					if(index == -1){
						count_on++;
						index = index2;
						list_images[i][0] = data[index];
						for(var j= index + 1;j<data.length-1;j++){
							if(list_images[i][0][8] == data[j][8] && data[j][8]){
								list_images[i].push(data[j]);
								index2++;
							}else{
								index2++;
								break;
							}						
						}
						list += "<li><a class='taga' value='"+ i +"'href='#'>" + list_images[i][0][3] + "</a></li>";
					}
					else {
						if(data[index][8] != data[index2][8] ){
							count_on++;
							index = index2;
							list_images[i][0] = data[index];
							for(var j= index + 1;j<data.length-1;j++){
								if(list_images[i][0][8] == data[j][8] && data[j][8]){
									list_images[i].push(data[j]);
									index2++;
								}else{
									index2++;
									break;
								}						
							}
							list += "<li><a class='taga' value='"+ i +"'href='#'>" + list_images[i][0][3] + "</a></li>";
						}
					}
				}
					list += "</ul>";
			}
			$('#onpress').html(list);

			if(count_on){
				site = new Object;
				site.info = list_images;
				$('.taga').click(function(){
					thumbnailviewer.loadonpress(site,$(this).attr('value'));
				});
			}
		},
		failure: function ( result, request ) {
    	}
	});
}
images.content = function(page_id){
	var divid = "";
	var str = "";
	switch(page_id){
		case 1:
			divid = 'aboutus';
			str = "<p class='titlebar'>&nbsp;&nbsp;&nbsp;&nbsp;ABOUT US</p>";
		break;
		case 3:
			divid = 'description';
		break
		case 6:
			divid = 'content_contact';
			str = "<h3><strong>WHEEL HOUSE CAFE</strong></h3>";
		break;
	}
	Ext.Ajax.request({
		url:  'includes/album.php',
		method: 'POST',
		params: {act : 'content',
				 page : page_id},
		success: function ( result, request ){
			var content = result.responseText.trim();
			arr = content.split('.-');
			for(var i =0;i<arr.length;i++){
				if (page_id != 6){
					str += "<p style='line-height:15px; font-size:12.5px; font-family:tahoma; text-align:justify'>" + arr[i] + "</p>";
				}else{
					arr[i]= arr[i].split(':');
					str += "<h3><strong>" + arr[i][0] +":</strong>"+ arr[i][1] +"</h3>";
				}
			}
			$('#' + divid).html(str);
		}
	});
}
images.logo = function (page_id,location){
	var divid = "";
	var str ="";
	switch (page_id){
		case 1:
			divid ='onpress_banner';
		break;
		case 6:
			divid = 'map';
		break;
	}
	Ext.Ajax.request({
		url:  'includes/album.php',
		method: 'POST',
		params: {act : 'logo',
				 page : page_id},
		success: function ( result, request ){
			var data = Ext.decode(result.responseText).images;
			if(page_id == 1 && data.length > 1){
				url = data[0][2];
				str = "<img src='"+ url +"' style='width:170px;height:240px'></img>";
				$('#' + divid).html(str);
			}
			if (page_id ==6 && data.length >1){
				url = data[0][2];
				str = "<img src='"+ url +"' style='position:absolute; top:80px; width:300px; height:150px;' alt='map' ></img>";
				$('#' + divid).html(str);
				url = data[0][2];
				str= "<a href='" + url  +"'><img src='" + url +"'  style='position:absolute; top:80px; width:300px; height:150px;' alt='map'></a>";
//				str = "<img src='"+ url +"' style='position:absolute; top:80px; width:300px; height:150px;' alt='map' ></img>";
				$('#' + divid).html(str);
				$('#' + divid + ' a').lightBox();


			}
		}
	});
}